package com.zzyl.common.utils;

import org.springframework.stereotype.Component;

@Component
public class UserThreadLocal {

    //定义内存容器供开发者存取
    private static final ThreadLocal<Long> CONTEXT = new ThreadLocal<>();

    //存入数据到内存中
    public static void setValue(Long userId) {
        CONTEXT.set(userId);
    }

    //从内存中获取数据
    public static Long getValue() {
        return CONTEXT.get();
    }

    //清理内存数据
    public static void clean() {
        CONTEXT.remove();
    }
}
